import { defineStore } from 'pinia'
import type { asideMenuType } from '@/types/asideMenuType'
import { saveToLocalStore, removeToLocalStore } from '@/common/index'
export const useAsideMenuStore = defineStore('asideMenu', {
  state: () => {
    return {
      asideMenu: [] as asideMenuType,
    }
  },
  actions: {
    // 清空AsideMenu
    clearAsideMenu() {
      this.asideMenu = []
      removeToLocalStore('asideMenu')
    },
    // 设置AsideMenu
    setAsideMenu(data: asideMenuType) {
      // console.log(2222,data);

      // this.asideMenu = data;
      this.asideMenu = data
      // saveToLocalStore('asideMenu', data);
    },
  },
  // persist: true, //持久化
  persist: {
    storage: localStorage,
    pick: ['asideMenu'],
    // key: 'asideMenu',
  },
})
